namespace NetworkPower.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitialCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.CableInventorys",
                c => new
                    {
                        CableInventoryId = c.Guid(nullable: false),
                        InstallCompany = c.String(),
                        CableUniqueNumber = c.String(),
                        CableType = c.String(),
                        BackUpCore = c.Int(nullable: false),
                        Start = c.String(),
                        End = c.String(),
                        LineLength = c.Decimal(nullable: false, precision: 18, scale: 2),
                        Memo = c.String(),
                    })
                .PrimaryKey(t => t.CableInventoryId);
            
            CreateTable(
                "dbo.CableLines",
                c => new
                    {
                        CableLineId = c.Guid(nullable: false),
                        CableLineNo = c.Guid(nullable: false),
                        LoopNo = c.String(),
                    })
                .PrimaryKey(t => t.CableLineId);
            
            CreateTable(
                "dbo.Departments",
                c => new
                    {
                        DepartmentId = c.Guid(nullable: false),
                        DepartmentName = c.String(nullable: false),
                        SheetIndex = c.Int(nullable: false),
                        LineProtectBoxId = c.Guid(nullable: false),
                    })
                .PrimaryKey(t => t.DepartmentId);
            
            CreateTable(
                "dbo.LoopLines",
                c => new
                    {
                        LoopLineId = c.Guid(nullable: false),
                        LoopLineName = c.String(),
                        LoopLineNameColor = c.String(),
                        InternalLine = c.String(),
                        TerminalNoText = c.String(nullable: false),
                        TerminalNoColor = c.String(),
                        OuterLine = c.String(),
                        LoopNo = c.String(),
                        DepartmentId = c.Guid(nullable: false),
                        RowIndex = c.Int(nullable: false),
                        IsMatch = c.Boolean(),
                        ShortConnectTo = c.Guid(nullable: false),
                        LineProtextId = c.Guid(nullable: false),
                        LineId = c.Guid(),
                    })
                .PrimaryKey(t => t.LoopLineId)
                .ForeignKey("dbo.Departments", t => t.DepartmentId, cascadeDelete: true)
                .Index(t => t.DepartmentId);
            
            CreateTable(
                "dbo.EquipmentNumbers",
                c => new
                    {
                        EquipmentNumberId = c.Guid(nullable: false),
                        EquipmentType = c.Int(nullable: false),
                        MaxNo = c.String(),
                    })
                .PrimaryKey(t => t.EquipmentNumberId);
            
            CreateTable(
                "dbo.Equipments",
                c => new
                    {
                        EquipmentID = c.Guid(nullable: false),
                        SeperationID = c.Guid(nullable: false),
                        EquipmentUnit = c.String(maxLength: 250),
                        EquipmentName = c.String(maxLength: 250),
                    })
                .PrimaryKey(t => new { t.EquipmentID, t.SeperationID });
            
            CreateTable(
                "dbo.LineProtectBoxs",
                c => new
                    {
                        LineProtectBoxId = c.Guid(nullable: false),
                        LineProtectBoxName = c.String(nullable: false, maxLength: 250),
                    })
                .PrimaryKey(t => new { t.LineProtectBoxId, t.LineProtectBoxName });
            
            CreateTable(
                "dbo.Projects",
                c => new
                    {
                        ProjectID = c.Guid(nullable: false),
                        ProjectName = c.String(nullable: false, maxLength: 250),
                        ProjectNumber = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => new { t.ProjectID, t.ProjectName });
            
            CreateTable(
                "dbo.Seperations",
                c => new
                    {
                        SeperationID = c.Guid(nullable: false),
                        SeperationType = c.String(nullable: false, maxLength: 50),
                        VoltageID = c.Guid(nullable: false),
                    })
                .PrimaryKey(t => new { t.SeperationID, t.SeperationType, t.VoltageID });
            
            CreateTable(
                "dbo.Users",
                c => new
                    {
                        UserName = c.String(nullable: false, maxLength: 250),
                        Password = c.String(nullable: false, maxLength: 50),
                        CreateDate = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => new { t.UserName, t.Password, t.CreateDate });
            
            CreateTable(
                "dbo.Voltages",
                c => new
                    {
                        VoltageID = c.Guid(nullable: false),
                        VoltageValue = c.String(nullable: false, maxLength: 50),
                        ProjectID = c.Guid(nullable: false),
                    })
                .PrimaryKey(t => new { t.VoltageID, t.VoltageValue, t.ProjectID });
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.LoopLines", "DepartmentId", "dbo.Departments");
            DropIndex("dbo.LoopLines", new[] { "DepartmentId" });
            DropTable("dbo.Voltages");
            DropTable("dbo.Users");
            DropTable("dbo.Seperations");
            DropTable("dbo.Projects");
            DropTable("dbo.LineProtectBoxs");
            DropTable("dbo.Equipments");
            DropTable("dbo.EquipmentNumbers");
            DropTable("dbo.LoopLines");
            DropTable("dbo.Departments");
            DropTable("dbo.CableLines");
            DropTable("dbo.CableInventorys");
        }
    }
}
